<%@ page import="java.sql.*" %><%--
  Created by IntelliJ IDEA.
  User: ghost
  Date: 2019/12/4
  Time: 18:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<table>
    <tr><td>id</td><td>书名</td><td>作者</td></tr>
<%
    Class.forName("com.mysql.jdbc.Driver");
    String sql = "select * from book";
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/stu","root","13209202523cyf");
    PreparedStatement pstm = con.prepareStatement(sql);
    ResultSet rs = pstm.executeQuery();
    while(rs.next()){
%>
    <tr><td><%=rs.getString("id")%></td><td><%=rs.getString("name")%></td><td><%=rs.getString("autor")%></td></tr>
<%
    }
    rs.close();
    pstm.close();
    con.close();
%>
</table>
</body>
</html>
